<!DOCTYPE html>
<html lang="en">
<head>
    <title>微信转发详细页</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        [v-cloak] {
            display: none;
        }

        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }

        body {
            margin: 1px;
        }

        table {
            border-spacing: 0;
            border-collapse: collapse;
            display: table;
        }

        table.text-center, table.text-center td, table.text-center th {
            text-align: center;
            font-size: x-small;
        }

        .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
            border: 1px solid #cbcbcd;
        }

        table th {
            background: #f8f8f8;
            padding-top: 5px;
            padding-bottom: 5px;
        }

        table td {
            padding-top: 5px;
            padding-bottom: 5px;
        }

        .table-bordered {
            border: 1px solid #cbcbcd;
        }

        .table {
            width: 100%;
            max-width: 100%;
            margin-bottom: 20px;
        }

        .hidden {
            display: none;
        }

        .title {
            text-align: center;
            font-size: small;
            margin-bottom: 5px;
        }

        .infoReport {
            text-align: center;
            font-size: x-small;
            margin-bottom: 5px;
        }

        .reginTd {
            max-width: 90px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            position: relative;
            cursor: pointer;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            background-color: #d3e8fd;
            padding: 8px 6px;
            font-size: x-small;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }
    </style>
</head>
<body>
<section v-cloak class="content" id="app" style="min-height:100vh">
    <div class="table-width title" style="margin-top: 5px;">{{userName}}{{time}}微信转发</div>
    <div class="div-td-content-more"><i></i></div>
    <div class="row">
        <div class="col-md-12">
            <div class="infoReport" v-if="isToday=='1'"><i></i>应转发：{{reportShare.todayForward}}&nbsp;&nbsp;已转发：{{reportShare.todayFinishForward}}&nbsp;&nbsp;未转发：{{reportShare.todayNoForward}}
            </div>
            <div class="infoReport" v-if="isToday=='0'"><i></i>应转发：{{reportShare.monthForward}}&nbsp;&nbsp;已转发：{{reportShare.monthFinishForward}}&nbsp;&nbsp;未转发：{{reportShare.monthNoForward}}
            </div>
            <table class="table table-bordered text-center table-width" v-if="isToday=='1'">
                <thead>
                <tr style="height: 30px">
                    <th>转发标题</th>
                    <th>转发次数</th>
                    <th>早上</th>
                    <th>中午</th>
                    <th>晚上</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,i) in list">
                    <td style="text-align: left;" class="reginTd">{{item.name}}</td>
                    <td>{{item.forwardNumber}}</td>
                    <td>
                        <i v-if="item.morningFlag==1">
                            <img style="width: 18px;" src="/dist/img/ic_app_right.png">
                        </i>
                        <i v-else-if="item.morningFlag==0">
                            <img style="width: 18px;" src="/dist/img/ic_app_worng.png">
                        </i>
                    </td>
                    <td>
                        <i v-if="item.noonFlag==1">
                            <img style="width: 18px;" src="/dist/img/ic_app_right.png">
                        </i>
                        <i v-else-if="item.noonFlag==0">
                            <img style="width: 18px;" src="/dist/img/ic_app_worng.png">
                        </i>
                    </td>
                    <td>
                        <i v-if="item.nightFlag===1">
                            <img style="width: 18px;" src="/dist/img/ic_app_right.png">
                        </i>
                        <i v-else-if="item.nightFlag==0">
                            <img style="width: 18px;" src="/dist/img/ic_app_worng.png">
                        </i>
                    </td>
                </tr>
                </tbody>
            </table>
            <table class="table table-bordered text-center table-width" v-if="isToday=='0'">
                <thead>
                <tr style="height: 30px">
                    <th style="width: 90px">日期</th>
                    <th style="width: 220px">转发标题</th>
                    <th style="width: 60px">转发<br/>次数</th>
                    <th style="width: 50px">早上</th>
                    <th style="width: 50px">中午</th>
                    <th style="width: 50px">晚上</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,i) in monthShareList">
                    <td :rowspan="item.shareDatespan" :class="{hidden: item.shareDatedis}">
                        {{item.shareDate}}
                    </td>
                    <td style="text-align: left;">{{item.name}}</td>
                    <td>{{item.forwardNumber}}</td>
                    <td>
                        <i v-if="item.morningFlag==1">
                            <img style="width: 18px;" src="/dist/img/ic_app_right.png">
                        </i>
                        <i v-else-if="item.morningFlag==0">
                            <img style="width: 18px;" src="/dist/img/ic_app_worng.png">
                        </i>
                    </td>
                    <td>
                        <i v-if="item.noonFlag==1">
                            <img style="width: 18px;" src="/dist/img/ic_app_right.png">
                        </i>
                        <i v-else-if="item.noonFlag==0">
                            <img style="width: 18px;" src="/dist/img/ic_app_worng.png">
                        </i>
                    </td>
                    <td>
                        <i v-if="item.nightFlag==1">
                            <img style="width: 18px;" src="/dist/img/ic_app_right.png">
                        </i>
                        <i v-else-if="item.nightFlag==0">
                            <img style="width: 18px;" src="/dist/img/ic_app_worng.png">
                        </i>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>

    </div>


    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script src="/dist/js/oaApp.js"></script>
<script type="text/javascript">
    $(function () {
        $("body").on("click", ".reginTd", function (e) {
            var text = $(this).text();
            if ($('.div-td-content-more').is(':hidden')) {
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $('.div-td-content-more').hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script type="text/javascript">
    function isDay(time) {
        //2018-01-01
        if (time.length > 8) {
            return true
        } else {
            return false
        }
    }

    var app = new Vue({
        el: '#app',
        data: {
            list: [],
            monthShareList: [],
            months: [],
            userId: getUrlParamObj().id,
            companyId: getUrlParamObj().companyId,
            time: "",
            today: "",
            userName: "",
            flag: "0",
            isToday: "1",
            reportShare: []
        },
        methods: {
            insert_flg: function (str, flg, sn) {
                var newstr = "";
                for (var i = 0; i < str.length; i += sn) {
                    var tmp = str.substring(i, i + sn);
                    newstr += tmp + flg;
                }
                newstr = newstr.substr(0, newstr.length - 1);
                return newstr;
            },
            getList: function () {
                var that = this;
                var data = {
                    "userId": that.userId,
                    "companyId": that.companyId,
                    "shareDate": that.time
                };
                $.ajax({
                    url: server.ip + urlConfig.system.wechatShare.getWechatShare,
                    contentType: 'application/json;charset=utf-8',
                    type: "POST",
                    data: JSON.stringify(data),
                    success: function (r) {
                        var res = JSON.parse(r)
                        that.list = res.data.sendData;
                    },
                    error: function (e) {
                        alert(e.responseText)
                    }
                });
            },
            getMonthShareList: function () {
                var that = this;
                var data = {
                    "userId": that.userId,
                    "companyId": that.companyId,
                    "shareMonth": that.time
                };
                $.ajax({
                    url: server.ip + urlConfig.system.wechatShare.getMonthShareList,
                    contentType: 'application/json;charset=utf-8',
                    type: "POST",
                    data: JSON.stringify(data),
                    success: function (r) {
                        var res = JSON.parse(r);
                        that.monthShareList = that.tablesMergeCell(res.data.sendData);
                    },
                    error: function (e) {
                        alert(e.responseText)
                    }
                });
            },
            getWechatShareTotal: function () {
                var that = this;
                var data = {
                    "userId": that.userId,
                    "shareMonth": that.time
                };
                $.ajax({
                    url: server.ip + urlConfig.system.wechatShare.getWechatShareTotal,
                    contentType: 'application/json;charset=utf-8',
                    type: "POST",
                    data: JSON.stringify(data),
                    success: function (r) {
                        var res = JSON.parse(r)
                        that.reportShare = res.data.sendData;
                    },
                    error: function (e) {
                        alert(e.responseText)
                    }
                });
            },
            tablesMergeCell: function (list) {
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != '') {
                                list[k][field + 'span']++;
                                list[k][field + 'dis'] = false;
                                list[i][field + 'span'] = 1;
                                list[i][field + 'dis'] = true;
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            }
        },
        mounted: function () {
            //获取前5个月
            var that = this;

            that.userId = getUrlParamObj().userId;
            that.userName = getUrlParamObj().userName;
            that.time = getUrlParamObj().time;
            that.isToday = (isDay(getUrlParamObj().time)) ? "1" : "0";
            that.companyId = getUrlParamObj().companyId;
            //查询某人所属公司
            var data = {
                "id": that.userId
            };
            $.ajax({
                url: server.ip + urlConfig.system.user.getUserViewById,
                contentType: 'application/json;charset=utf-8',
                type: "POST",
                data: JSON.stringify(data),
                success: function (r) {
                    var res = JSON.parse(r)
                    that.companyId = res.data.sendData.companyId;
                    if (that.isToday == "1") {
                        that.getList();
                    } else {
                        that.getMonthShareList();
                    }
                    that.getWechatShareTotal();
                },
                error: function (e) {
                    alert(e.responseText)
                }
            });
        }

    });
</script>

</body>
</html>